<template>
    <div class="roleHasUser">
        <table-index
            :dataSource="dataSource"
            :tableColumns="tableColumns"
            :btnList="btnList"
            :pageSize="pageSize"
            :pageCount="pageCount"
            :pageNo="pageNo"
            @pageChange="pageChange"
            selection
            @handleSelectionChange="handleSelectionChange"
        ></table-index>

        <div style="text-align: left; margin-top: 20px">
            <el-button type="primary" @click="onSubmit">确定</el-button>
            <el-button @click="dialogTableClose">取消</el-button>
        </div>
    </div>
</template>

<script>
import tableIndex from "@/components/customComponents/customeTable/tableIndex"
import {Utility} from "@/libs/utility"
import {roleList} from "@/mockData/systemManage.js"
import {PopupCommon} from "@/libs/popupCommon"
export default {
    props: ["roleId"],
    components: {
        tableIndex
    },
    data() {
        return {
            selectDeviceList: [],
            userName: "",
            roleName: "",
            device_type: "",
            device_typeList: Utility.getDictList("device_type"),
            status: "",
            statusList: Utility.getDictList("status"),
            // table 相关参数  begin
            dataSource: roleList,
            tableColumns: [
                {
                    prop: "name",
                    label: "角色名称"
                },
                {
                    prop: "remark",
                    label: "备注"
                },
                {
                    prop: "isNormal",
                    label: "是否启用",
                    dictName: "trueOrFalse"
                }
            ],
            btnList: [],
            pageSize: 20,
            pageCount: 3,
            pageNo: 1
            // table 相关参数  end
        }
    },
    methods: {
        handleSelectionChange(d) {
            this.selectDeviceList = d
        },
        onSubmit() {
            if (this.selectDeviceList.length == 0) {
                PopupCommon.notify("info", "请选择角色")
                return
            }
            this.dialogTableClose()
        },
        dialogTableClose() {
            this.$emit("close", this.selectDeviceList)
        },
        pageChange(p) {
            this.pageNo = p
            this.initPage()
        },
        initPage() {
            //   let self = this;
            //   AjaxCommon("/ccdc/cfg/device/device/listByPage", "post", {
            //     userName: this.userName,
            //     deviceStatus: this.status,
            //     deviceType: this.device_type,
            //     pageNo: this.pageNo,
            //     pageSize: this.pageSize,
            //   }).then((res) => {
            //     if (res.data.code == 200) {
            //       self.dataSource = res.data.result.records;
            //       self.pageCount = res.data.result.total;
            //     } else {
            //       PopupCommon.notify("error", res.data.message);
            //     }
            //   });
        }
    },
    mounted() {
        this.initPage()
    }
}
</script>

<style>
.roleHasUser {
    .mcTableIndex {
        height: 400px;
    }
}
</style>
